package com.programming.forum.controller;

import com.programming.forum.common.AppResult;
import com.programming.forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22479
 * Date: 2023-11-04
 * Time: 17:59
 */
@Api(tags = "test测试类")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试接口2 测试异常")
    @GetMapping("/exception")
    public AppResult testException() throws Exception {
        throw new Exception("异常测试");
    }
    @ApiOperation("测试接口3 测试自定义异常")
    @GetMapping("/application")
    public AppResult testException2() throws Exception {
        throw new ApplicationException("applicationException");
    }

    @ApiOperation("测试接口1 返回hello")
    @GetMapping("hello")
    public String print() {
        return "hello";
    }

    @ApiOperation("测试接口3 返回hello talk")
    @PostMapping("/hellotalk")
    public String print(@ApiParam(value="你要说的话") @RequestParam("talk") String talk) {
        return "hello" + talk;
    }
}
